# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import datetime
import json
import codecs
import sys
reload(sys)
sys.setdefaultencoding("utf-8")

class ProductinfoPipeline(object):
	def __init__(self):
		filename = 'product'+str(datetime.date.today())+'.txt'
		self.file = codecs.open(filename, 'wb', encoding='utf-8')
	def process_item(self, item, spider):
		print item
		self.file.write(json.dumps(dict(item), ensure_ascii=False)+"\n")
		return item
